package com.shu.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shu.pojo.Type;
import com.shu.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author shu
 * @date 2021/3/23
 */

/**
 * 文章类型控制器
 */
@Controller
public class TypeController {

    @Autowired
    TypeService typeService;

    /**
     * 首页初始化数据
     * @param model
     * @return
     */
    @RequestMapping({"/","view/index"})
    public String Index_Type(Model model){
        QueryWrapper<Type> wrapper = new QueryWrapper<>();
        wrapper.select("tid","name","url");
        List<Type> list = typeService.list(wrapper);
        model.addAttribute("lists",list);
        return "index";
    }


}
